import 'dart:io';import 'package:easy_localization/easy_localization.dart';import 'package:flutter/cupertino.dart';import 'package:flutter/material.dart';import 'package:flutter/services.dart';import 'package:fluttertoast/fluttertoast.dart';import 'package:flutter_svg/flutter_svg.dart';import 'package:gcglobal/GCModel/GCBuildHouseModel.dart';import 'package:gcglobal/GCModel/GCHouseFileModel.dart';import 'package:gcglobal/GCModel/GCHouseItemModel.dart';import 'package:gcglobal/GCModel/GCHouseTypeDetailModel.dart';import 'package:gcglobal/HomePage/AddInvoice/GCAddInvoicePageView.dart';import 'package:gcglobal/HomePage/HouseDataListPage/GCHouseFileDataPageView.dart';import 'package:gcglobal/HomePage/HouseDataListPage/GCHouseTypeDetailPageView.dart';import 'package:gcglobal/HomePage/HouseDataListPage/GCHouseTypeListPageView.dart';import 'package:gcglobal/HomePage/RecordList/GCDealDetailPageView.dart';import 'package:gcglobal/HomePage/Wights/GCBuildHouseHeader.dart';import 'package:gcglobal/HomePage/Wights/GCHouseItemListView.dart';import 'package:gcglobal/HomePage/Wights/GCTopicHouseWidget.dart';import 'package:gcglobal/Services/tools/DioManager.dart';import 'package:map_launcher/map_launcher.dart';import 'package:permission_handler/permission_handler.dart';import 'package:share/share.dart';import 'package:sp_util/sp_util.dart';import 'package:tab_indicator_styler/tab_indicator_styler.dart';import 'package:url_launcher/url_launcher.dart';import 'package:video_player/video_player.dart';import 'GCHouseBaseMessagePageView.dart';class GCHouseDataDetailPageView extends StatefulWidget{  GCBuildHouseModel? model;  GCHouseDataDetailPageView(this.model);  @override  State<StatefulWidget> createState() {    // TODO: implement createState    return GCHouseDataDetailState();  }}class GCHouseDataDetailState extends State<GCHouseDataDetailPageView> with TickerProviderStateMixin {  ScrollController _scrollController = new ScrollController();  final GlobalKey<GCHouseItemListState>? houseTypeKey = GlobalKey();  final GlobalKey lookHouseKey = GlobalKey();  final GlobalKey buildFieldKey = GlobalKey();  final GlobalKey huxingIntroKey = GlobalKey();  final GlobalKey positionKey = GlobalKey();  String houseStatus = "";  double opacity = 0.0;  bool showMap = false;  double maxScroll = 0.0;  Map<String,GCHouseFileModel> allFileModel = {} ;  List<Widget> _tabs = <Widget>[    Tab(      child: Column(        children: [          Container(            // child: ,          ),          Container(            height: 500,            color: Colors.red,          )        ],      ),    ),  ];  List<GCTopicTagWidget> tagList = [];  List<GCHouseItemModel>? houseTypeList = [];  List<Widget> _tabViews = <Widget>[    Column(      children: [        Container(          height: 500,          color: Colors.blue,        ),        Container(          height: 500,          color: Colors.red,        )      ],    )  ];  TabController? _tabController;  TabController? _tagTabController;  ScrollController? scrollController;  @override  void initState() {    super.initState();    this._tabController = TabController(length: _tabs.length, vsync: this);    this._tagTabController = TabController(length: 5,vsync: this);    this._tagTabController!.addListener(() {      double maxOffset = this.scrollController!.position.maxScrollExtent;      if(this._tagTabController!.index==0){        this.scrollController!.animateTo(0, duration: Duration(milliseconds: 1), curve: Curves.easeInSine);      }else if(this._tagTabController!.index == 1){       if(maxOffset>396){         this.scrollController!.animateTo(396, duration: Duration(milliseconds: 1), curve: Curves.easeInSine);       }      }else if(this._tagTabController!.index == 2){       if(maxOffset>433){         if(widget.model!.vRImage!.length <= 0){           this.scrollController!.animateTo(433, duration: Duration(milliseconds: 1), curve: Curves.easeInSine);         }else{           this.scrollController!.animateTo(590, duration: Duration(milliseconds: 1), curve: Curves.easeInSine);         }       }else{         this._tagTabController!.index = 2;       }      }else if(this._tagTabController!.index == 3){        if(widget.model!.vRImage!.length <= 0){          if(maxOffset > 566){            if(widget.model!.houseTypeItemCount!.length<= 0 ){              this.scrollController!.animateTo(500, duration: Duration(milliseconds: 1), curve: Curves.easeInSine);            }else{              this.scrollController!.animateTo(566, duration: Duration(milliseconds: 1), curve: Curves.easeInSine);            }          }else{            this._tagTabController!.index = 3;          }        }else{          if(maxOffset > 566){            if(widget.model!.houseTypeItemCount!.length<= 0 ){              this.scrollController!.animateTo(450, duration: Duration(milliseconds: 1), curve: Curves.easeInSine);            }else{              this.scrollController!.animateTo(609, duration: Duration(milliseconds: 1), curve: Curves.easeInSine);            }          }else{            this._tagTabController!.index = 3;          }        }      }else{        // if(maxScroll > 1000){        //   this.scrollController!.animateTo(1000, duration: Duration(milliseconds: 1), curve: Curves.easeInSine);        // }else{          this._tagTabController!.index= 4;        // }      }    });    this.scrollController = ScrollController();    this.scrollController!.addListener(() {      int offset = this.scrollController!.position.pixels.toInt();      print(this.scrollController!.position.maxScrollExtent);      // 如果滑动到底部      if (this.scrollController!.position.pixels == this.scrollController!.position.maxScrollExtent) {        return;      }     if(this.scrollController!.position.maxScrollExtent > 700){       if(this._tagTabController!.index > 1&&this.scrollController!.offset<=maxScroll){         return;       }       if(this.scrollController!.offset <200){         this._tagTabController!.index = 0;       }else if(this.scrollController!.offset>=200&&this.scrollController!.offset<566){         this._tagTabController!.index= 1;       }else if(this.scrollController!.offset>=566&&this.scrollController!.offset<700){         this._tagTabController!.index = 2;       }else if(this.scrollController!.offset>=700&& this.scrollController!.offset<800){         this._tagTabController!.index = 3;       }else {         this._tagTabController!.index = 4;       }     }    });    // List<String> tempTag = widget.model!.status??[];    widget.model!.status!.forEach((element) {      tagList.add(GCTopicTagWidget(title: element,bgColor: Colors.blueAccent,));    });    print("========================");    print(widget.model!.status);    print(tagList);    getHouseTypeList("");    getFileData();  }  void getFileData(){    DioManager.getInstance()!.post("crm/House/HouseFiles", {      "SessionKey":SpUtil.getString("sk"),"UserID":SpUtil.getString("uid"),      "HouseID":widget.model!.houseID!    }, (data){        allFileModel.addEntries({"Category1":GCHouseFileModel.fromJson(data["Category_1"])}.entries);        allFileModel.addEntries({"Category2":GCHouseFileModel.fromJson(data["Category_2"])}.entries);        allFileModel.addEntries({"Category3":GCHouseFileModel.fromJson(data["Category_3"])}.entries);        allFileModel.addEntries({"Category4":GCHouseFileModel.fromJson(data["Category_4"])}.entries);    }, (error){    });  }  void getHouseTypeList(roomCount){      DioManager.getInstance()!.post("crm/House/HouseTypeLists", {        "SessionKey":SpUtil.getString("sk"),        "UserID":SpUtil.getString("uid"),        "p":"1",        "pp":"99",        "RoomCount":roomCount??"",        "HouseID":widget.model!.houseID!      }, (data){        if(data.length > 0) {          houseTypeList!.clear();          data.forEach((e) =>houseTypeList!.add(GCHouseItemModel.fromJson(e)));          houseTypeKey!.currentState!.refreshView(houseTypeList!);          setState(() {          });        }else{        }      }, (error){          Fluttertoast.showToast(msg: error,gravity: ToastGravity.CENTER);      });  }  @override  void dispose() {    // TODO: implement dispose    super.dispose();  }  @override  Widget build(BuildContext context) {    // TODO: implement build    return Scaffold(      body:NotificationListener<ScrollNotification>(        onNotification:  (ScrollNotification notification) {          maxScroll =  notification.metrics.maxScrollExtent;          return true;        },        child: CustomScrollView(          controller: scrollController,          slivers: [            SliverPersistentHeader(              floating: true,              pinned: true,              delegate: SliverCustomHeaderDelegate(                  collapsedHeight:100.0,                  expandedHeight: MediaQuery.of(context).size.width*(266.0/375.0),                  paddingTop: 20.0,                  coverImgUrls:widget.model!.images!,                  videoUrls: widget.model!.videos!,                  title: "练习",                  tagTabController: _tagTabController,                  coverPicUrl: widget.model!.imageUrl!,                  videoImageUrls: widget.model!.videoImages!,                  model: widget.model!              ),            ),            SliverList(              delegate: SliverChildListDelegate([                Container(                  child: Text(                    widget.model!.name!,                    style: TextStyle(                        fontSize: 18,                        color: Color(0xFF333333),                        fontWeight: FontWeight.w500                    ),                  ),                  margin: EdgeInsets.only(left: 15,right: 15,top: 0),                ),                ///tag行                Container(                  height: 30,                  margin: EdgeInsets.only(left: 5,right: 15,top: 6),                  child: Row(                    children: tagList,                  ),                ),                Container(                  child: Text(                    "¥${widget.model!.price!}/m²起",                    style: TextStyle(                        fontSize: 16,                        color: Color(0xFFFF244C),                        fontWeight: FontWeight.w500                    ),                  ),                  margin: EdgeInsets.only(left: 15,right: 15,top: 5),                ),                Container(                  color: Color(0xFFF4F4F4),                  margin: EdgeInsets.only(left: 0,right: 0,top: 10),                  padding: EdgeInsets.only(left: 15,right: 0,bottom: 15),                  child: Column(                    children: [                      Container(                        width: MediaQuery.of(context).size.width,                        margin: EdgeInsets.only(top: 10),                        height: 17,                        child: Row(                          children: [                            Container(                              width:MediaQuery.of(context).size.width/2,                              child: Row(                                children: [                                  Text(                                    "總價：",                                    style: TextStyle(                                      fontSize: 12,                                      color: Color(0xFF999999),                                    ),                                  ),                                  Text(                                    "${widget.model!.totalPrice}"+"萬/套起",                                    style: TextStyle(                                      color: Color(0xFFFF244C),                                      fontSize: 12,                                    ),                                  ),                                ],                              ),                            ),                            Text(                              "用途：",                              style: TextStyle(                                fontSize: 12,                                color: Color(0xFF999999),                              ),                            ),                            Text(                              widget.model!.use!,                              style: TextStyle(                                color: Color(0xFF333333),                                fontSize: 12,                              ),                            ),                          ],                        ),                      ),                      Container(                        height: 17,                        width: MediaQuery.of(context).size.width,                        margin:EdgeInsets.only(top: 8),                        child: Row(                          children: [                            Container(                              width:MediaQuery.of(context).size.width/2,                              child: Row(                                children: [                                  Text(                                    "房間：",                                    style: TextStyle(                                      fontSize: 12,                                      color: Color(0xFF999999),                                    ),                                  ),                                  Text(                                    "${widget.model!.minCount!}-${widget.model!.maxCount}"+"室",                                    style: TextStyle(                                      color: Color(0xFF333333),                                      fontSize: 12,                                    ),                                  ),                                ],                              ),                            ),                            Text(                              "面積：",                              style: TextStyle(                                fontSize: 12,                                color: Color(0xFF999999),                              ),                            ),                            Text(                              "${widget.model!.minAcreage!}-${widget.model!.maxAcreage!}m²",                              style: TextStyle(                                color: Color(0xFF333333),                                fontSize: 12,                              ),                            ),                          ],                        ),                      ),                      Container(                        height: 17,                        width: MediaQuery.of(context).size.width,                        margin:EdgeInsets.only(top: 8),                        child: Row(                          children: [                            Container(                              child: Row(                                children: [                                  Text(                                    "收樓時間：",                                    style: TextStyle(                                      fontSize: 12,                                      color: Color(0xFF999999),                                    ),                                  ),                                  Text(                                    widget.model!.sltime!,                                    style: TextStyle(                                      color: Color(0xFF333333),                                      fontSize: 12,                                    ),                                  ),                                ],                              ),                              width:MediaQuery.of(context).size.width/2,                            ),                            Text(                              tr("裝修："),                              style: TextStyle(                                fontSize: 12,                                color: Color(0xFF999999),                              ),                            ),                            Text(                              widget.model!.zbbz??"",                              style: TextStyle(                                color: Color(0xFF333333),                                fontSize: 12,                              ),                            ),                          ],                        ),                      ),                      Container(                        margin:EdgeInsets.only(top: 8),                        child: Row(                          children: [                            Container(                              child: Row(                                children: [                                  Text(                                    tr("發展商："),                                    style: TextStyle(                                      fontSize: 12,                                      color: Color(0xFF999999),                                    ),                                  ),                                  Text(                                    widget.model!.fzs!,                                    style: TextStyle(                                      color: Color(0xFF333333),                                      fontSize: 12,                                    ),                                  ),                                ],                              ),                              width: MediaQuery.of(context).size.width/2,                            ),                            Container(                              child: Row(                                children: [                                  Text(                                    tr("樓盤均價："),                                    style: TextStyle(                                        fontSize: 12,                                        color: Color(0xFF999999),                                        fontWeight: FontWeight.w400                                    ),                                  ),                                  Text(                                    widget.model!.price!+"元/m²",                                    style: TextStyle(                                        color: Color(0xFF333333),                                        fontSize: 12                                    ),                                    overflow: TextOverflow.clip,                                    softWrap: true,                                    maxLines: 999,                                  )                                ],                              ),                            )                          ],                        ),                      ),                      Container(                        margin:EdgeInsets.only(top: 8),                        child: Row(                          children: [                            Container(                              child: Row(                                children: [                                  Text(                                    tr("維修費："),                                    style: TextStyle(                                      fontSize: 12,                                      color: Color(0xFF999999),                                    ),                                  ),                                  Text(                                    widget.model!.maintenanceCost!+"元",                                    style: TextStyle(                                      color: Color(0xFF333333),                                      fontSize: 12,                                    ),                                  ),                                ],                              ),                              width: MediaQuery.of(context).size.width/2,                            ),                            Container(                              child: Row(                                children: [                                  Text(                                    tr("管理費用："),                                    style: TextStyle(                                        fontSize: 12,                                        color: Color(0xFF999999),                                        fontWeight: FontWeight.w400                                    ),                                  ),                                  Text(                                    widget.model!.glf!+"元/m²",                                    style: TextStyle(                                        color: Color(0xFF333333),                                        fontSize: 12                                    ),                                    overflow: TextOverflow.clip,                                    softWrap: true,                                    maxLines: 999,                                  )                                ],                              ),                            )                          ],                        ),                      ),                      Container(                        margin:EdgeInsets.only(top: 8),                        child: Row(                          children: [                            Container(                              child: Row(                                children: [                                  Text(                                    tr("總戶數："),                                    style: TextStyle(                                      fontSize: 12,                                      color: Color(0xFF999999),                                    ),                                  ),                                  Text(                                    "${tr("共")}${widget.model!.zdhs!}${tr("戶")}",                                    style: TextStyle(                                      color: Color(0xFF333333),                                      fontSize: 12,                                    ),                                  ),                                ],                              ),                              width: MediaQuery.of(context).size.width/2,                            ),                            Container(                              child: Row(                                children: [                                  Text(                                    tr("樓盤類型："),                                    style: TextStyle(                                        fontSize: 12,                                        color: Color(0xFF999999),                                        fontWeight: FontWeight.w400                                    ),                                  ),                                  Text(                                    widget.model!.use!,                                    style: TextStyle(                                        color: Color(0xFF333333),                                        fontSize: 12                                    ),                                    overflow: TextOverflow.clip,                                    softWrap: true,                                    maxLines: 999,                                  )                                ],                              ),                            )                          ],                        ),                      ),                      Container(                        margin:EdgeInsets.only(top: 8),                        child: Row(                          children: [                            Container(                              child: Row(                                children: [                                  Text(                                    tr("交樓日期："),                                    style: TextStyle(                                      fontSize: 12,                                      color: Color(0xFF999999),                                    ),                                  ),                                  Text(                                    widget.model!.sltime!,                                    style: TextStyle(                                      color: Color(0xFF333333),                                      fontSize: 12,                                    ),                                  ),                                ],                              ),                              width: MediaQuery.of(context).size.width/2,                            ),                          ],                        ),                      ),                      Container(                        margin:EdgeInsets.only(top: 8),                        child: Row(                          crossAxisAlignment: CrossAxisAlignment.start,                          children: [                            Container(                              child: Row(                                children: [                                  Text(                                    tr("樓盤地址："),                                    style: TextStyle(                                      fontSize: 12,                                      color: Color(0xFF999999),                                    ),                                  ),                                  Expanded(child: Text(                                    widget.model!.address!,                                    style: TextStyle(                                      color: Color(0xFF333333),                                      fontSize: 12,                                    ),                                    softWrap: true,                                    maxLines: 999,                                  )),                                ],                              ),                              width: MediaQuery.of(context).size.width-100,                            ),                          ],                        ),                      ),                    ],                  ),                ),                Container(                  margin: EdgeInsets.only(left: 15,right: 15,top: 20),                  child: Row(                    mainAxisAlignment: MainAxisAlignment.spaceBetween,                    children: [                      Text(                        tr("樓盤賣點"),                        style: TextStyle(                            color: Color(0xFF333333),                            fontSize: 16                        ),                      ),                      Spacer(),                    ],                  ),                ),                Container(                  color: Color(0xFFF4F4F4),                  margin: EdgeInsets.only(left: 0,right: 0,top: 10),                  padding: EdgeInsets.only(left: 15,right: 0,bottom: 15,top: 15),                  child:   Text(                    widget.model!.sellPoint!,                    style: TextStyle(                      color: Color(0xFF333333),                      fontSize: 12,                    ),                    softWrap: true,                    maxLines: 999,                  ),                ),                GestureDetector(                  child: Container(                    child: Row(                      crossAxisAlignment: CrossAxisAlignment.center,                      children: [                        Container(height: 20,width: 30,                        margin: EdgeInsets.only(left: 15,top: 20),                        decoration: BoxDecoration(                          image: DecorationImage(                            image: AssetImage("assets/youtube.png")                          )                        ),),                        Container(                          child: Text(                            tr("YouTube"),                            style: TextStyle(                                color: Color(0xFF333333),                                fontSize: 16                            ),                          ),                          margin: EdgeInsets.only(left: 0,top: 20),                        ),                        // Expanded(child: Container(                        //                        //   child: Text(                        //     widget.model!.youtubeUrl!,                        //     style: TextStyle(                        //         color: Colors.blueAccent,                        //         fontSize: 16                        //     ),                        //     maxLines: 2,                        //   ),                        //   margin: EdgeInsets.only(left: 15,top: 20),                        // )),                      ],                    ),                  ),                  onTap: (){                    launchUrl(Uri.parse(widget.model!.youtubeUrl!));                  },                ),                Container(                  key:lookHouseKey,                  child: Text(                    tr("360睇樓"),                    style: TextStyle(                        color: Color(0xFF333333),                        fontSize: 16                    ),                  ),                  margin: EdgeInsets.only(left: 15,top: 20),                ),                widget.model!.vRImage!.length<=0?Container(): GestureDetector(                  child: AspectRatio(                    aspectRatio: 354.0/194.0,                    child: Container(                      margin: EdgeInsets.only(left: 15,right: 15,top: 10),                      decoration: BoxDecoration(                          image: DecorationImage(                              image: NetworkImage(widget.model!.vRImage!),                              fit: BoxFit.fitWidth                          ),                          shape: BoxShape.rectangle,                          borderRadius: BorderRadius.all(Radius.circular(10))                      ),                      child: Container(                        height: 70,                        width: 70,                        decoration: BoxDecoration(                            image: DecorationImage(                                image: AssetImage("assets/house_data/360_see/icon_360dilou@2x.png")                            )                        ),                      ),                      alignment: Alignment.center,                    ),                  ),                  onTap: ()async{                    await launchUrl(Uri.https(widget.model!.vRUrl!, ""));                  },                ),                GestureDetector(                  key:buildFieldKey,                  child: Container(                    margin: EdgeInsets.only(left: 15,right: 15,top: 20),                    child: Row(                      mainAxisAlignment: MainAxisAlignment.spaceBetween,                      children: [                        Text(                          tr("地產文件"),                          style: TextStyle(                              color: Color(0xFF333333),                              fontSize: 16                          ),                        ),                        Spacer(),                        Text(                          tr("查看全部"),                          style: TextStyle(                              color: Color(0xFF333333),                              fontSize: 12                          ),                        ),                        Container(                          height:16,                          width:16,                          decoration: BoxDecoration(                              image: DecorationImage(                                  image: AssetImage("assets/homepage/right_anchor/icon_youjiantou_X@2x.png")                              )                          ),                        )                      ],                    ),                  ),                  onTap: (){                    Navigator.push(context, MaterialPageRoute(builder: (context){                      return GCHouseFileDataPageView(widget.model!,allFileModel);                    }));                  },                ),                Container(                  margin: EdgeInsets.only(left: 15,right: 15,top: 10),                  padding: EdgeInsets.only(left: 20,right: 0,top: 10,bottom: 10),                  child: Column(                    children: [                      Row(                        mainAxisAlignment: MainAxisAlignment.spaceBetween,                        children: [                          Expanded(child: Container(                            child: Row(                              children: [                                Container(                                  height: 24,                                  width: 24,                                  decoration: BoxDecoration(                                      image : DecorationImage(                                          image: AssetImage("assets/house_data/shuomingshu/icon_shuomingshu@2x.png")                                      )                                  ),                                ),                                Container(                                  margin: EdgeInsets.only(left: 12),                                  child: Text(                                    tr("售樓說明書"),                                    style: TextStyle(                                        color: Color(0xFF333333),                                        fontSize: 14                                    ),                                  ),                                )                              ],                            ),                          )),                          Container(width: 20,),                          Expanded(child: Container(                            child: Row(                              children: [                                Container(                                  height: 24,                                  width: 24,                                  decoration: BoxDecoration(                                      image : DecorationImage(                                          image: AssetImage("assets/house_data/jiadan/icon_jiadan@2x.png")                                      )                                  ),                                ),                                Container(                                  margin: EdgeInsets.only(left: 12),                                  child: Text(                                    tr("價單"),                                    style: TextStyle(                                        color: Color(0xFF333333),                                        fontSize: 14                                    ),                                  ),                                )                              ],                            ),                          ))                        ],                      ),                      Container(height: 20,),                      Row(                        mainAxisAlignment: MainAxisAlignment.spaceBetween,                        children: [                          Expanded(child: Container(                            child: Row(                              children: [                                Container(                                  height: 24,                                  width: 24,                                  decoration: BoxDecoration(                                      image : DecorationImage(                                          image: AssetImage("assets/house_data/xiaoshouanpai/icon_xiaoshouanpai@2x.png")                                      )                                  ),                                ),                                Container(                                  margin: EdgeInsets.only(left: 12),                                  child: Text(                                    tr("銷售安排"),                                    style: TextStyle(                                        color: Color(0xFF333333),                                        fontSize: 14                                    ),                                  ),                                )                              ],                            ),                          )),                          Container(width: 20,),                          Expanded(child: Container(                            child: Row(                              children: [                                Container(                                  height: 24,                                  width: 24,                                  decoration: BoxDecoration(                                      image : DecorationImage(                                          image: AssetImage("assets/house_data/chengjiaojilu/icon_chengjiaojiluce@2x.png")                                      )                                  ),                                ),                                Container(                                  margin: EdgeInsets.only(left: 12),                                  child: Text(                                    tr("成交記錄冊"),                                    style: TextStyle(                                        color: Color(0xFF333333),                                        fontSize: 14                                    ),                                  ),                                )                              ],                            ),                          ))                        ],                      )                    ],                  ),                  decoration: BoxDecoration(                      color: Color(0xFFF4F4F4),                      shape: BoxShape.rectangle,                      borderRadius: BorderRadius.all(Radius.circular(10))                  ),                ),                GestureDetector(                  child: Container(                    key:huxingIntroKey,                    margin: EdgeInsets.only(left: 15,right: 15,top: 20),                    child: Row(                      mainAxisAlignment: MainAxisAlignment.spaceBetween,                      children: [                        Text(                          tr("戶型介紹")+"(${widget.model!.houseTypeCount!})",                          style: TextStyle(                              color: Color(0xFF333333),                              fontSize: 16                          ),                        ),                        Spacer(),                        Text(                          tr("全部戶型"),                          style: TextStyle(                              color: Color(0xFF333333),                              fontSize: 12                          ),                        ),                        Container(                          height:16,                          width:16,                          decoration: BoxDecoration(                              image: DecorationImage(                                  image: AssetImage("assets/homepage/right_anchor/icon_youjiantou_X@2x.png")                              )                          ),                        )                      ],                    ),                  ),                  onTap: (){                    Navigator.push(context, MaterialPageRoute(builder: (context){                      return GCHouseTypeListPageView(widget.model!);                    }));                  },                ),                Container(                  margin: EdgeInsets.only(top: 15,left: 15),                  height: 20,                  child: ListView.builder(itemBuilder: (BuildContext context,int index){                    List tempList = ["一","二","三","四","五","六","七"];                    return GestureDetector(                      child: Container(                        child: Text(                          "${tempList[int.parse(widget.model!.houseTypeItemCount![index].roomCount!.toString())-1]}"+"室(${widget.model!.houseTypeItemCount![index].count!})",                          style: TextStyle(                              fontSize: 12,                              color: Color(0xFF333333),                              decoration: TextDecoration.underline,                              decorationColor: Color(0xFF333333)                          ),                        ),                        margin: EdgeInsets.only(right: 20),                      ),                      onTap: (){                        getHouseTypeList(widget.model!.houseTypeItemCount![index].roomCount!);                      },                    );                  },itemCount: widget.model!.houseTypeItemCount!.length,scrollDirection:Axis.horizontal ),                ),                GCHouseItemListView(houseTypeList!,houseTypeKey!),                Container(                  key:positionKey,                  margin: EdgeInsets.only(left: 15,right: 15,top: 20),                  child: Text(                    tr("樓盤位置"),                    style: TextStyle(                        color: Color(0xFF333333),                        fontSize: 16                    ),                  ),                ),                GestureDetector(                  child:Row(                    children: [                      Expanded(                        child: Container(                          margin: EdgeInsets.only(left: 15,top: 10),                          child: Text(                            "${widget.model!.address!}",                            maxLines: 999,                            style: TextStyle(                                color: Color(0xFF333333),                                fontSize: 16                            ),                          ),                        ),                      ),                      Container(                        margin: EdgeInsets.only(left: 15,top: 10,right: 15),                        child: Text(                          "(點擊查看)",                          style: TextStyle(                              color: Color(0xFF333333),                              fontSize: 12                          ),                        ),                      )                    ],                  ),                  onTap: (){                    MapsSheet.show(context: context, onMapTap: (AvailableMap map){                      map.showMarker(                        coords: Coords(double.parse(widget.model!.lat!), double.parse(widget.model!.lng!)),                        title: widget.model!.name!,                        zoom: 13,                      );                    });                  },                ),                Container(                  height: 40,                ),                GestureDetector(                    child: Container(                      width: MediaQuery.of(context).size.width,                      height: 50,                      decoration: BoxDecoration(                          color: Colors.white,                          border: Border(top: BorderSide(color: Color(0xFFC5C5C5)))                      ),                      child: Container(                        margin: EdgeInsets.only(top: 7,bottom: 7,right: 55,left: 55),                        child: Text(                          tr("生成發票"),                          style: TextStyle(                              fontSize: 16,                              color: Color(0xFFB03725)                          ),                        ),                        decoration: BoxDecoration(                            color: Colors.white,                            borderRadius: BorderRadius.all(Radius.circular(4)),                            border: Border.all(color:Color(0xFFB03725))                        ),                        alignment: Alignment.center,                      ),                    ),                    onTap:(){                      Navigator.push(context, MaterialPageRoute(builder: (context){                        return GCAddInvoicePageView(1,houseModel: widget.model!,typeModel:GCHouseTypeDetailModel(),);                      },settings: RouteSettings(name: "/HouseData")));                    }                ),                Container(                  height: 30,                  color: Colors.white,                )              ]),            )          ],        ),      ),    );  }}class MapsSheet {  static show({    required BuildContext context,    required Function(AvailableMap map) onMapTap,  }) async {    final availableMaps = await MapLauncher.installedMaps;    showModalBottomSheet(      context: context,      builder: (BuildContext context) {        return SafeArea(          child: Column(            children: <Widget>[              Expanded(                child: SingleChildScrollView(                  child: Container(                    child: Wrap(                      children: <Widget>[                        for (var map in availableMaps)                          ListTile(                            onTap: () => onMapTap(map),                            title: Text(map.mapName),                            leading: SvgPicture.asset(                              map.icon,                              height: 30.0,                              width: 30.0,                            ),                          ),                      ],                    ),                  ),                ),              ),            ],          ),        );      },    );  }}class SliverCustomHeaderDelegate  extends SliverPersistentHeaderDelegate {  final double collapsedHeight;  ///折叠的高度  final double expandedHeight;  ///展开的高度  final double paddingTop;  final List<String> coverImgUrls;  final List<String> videoUrls ;  final String title;  ///視頻封面圖  final List<String> videoImageUrls;  double opacity = 0.0;  bool isBlackIcon = false;  TabController? tagTabController;  final String coverPicUrl;  ///0--視頻，1--圖片  int selectType = 0;  GCBuildHouseModel model;  SliverCustomHeaderDelegate({    required this.collapsedHeight,    required this.expandedHeight,    required this.paddingTop,    required this.coverImgUrls,    required this.title,    required this.tagTabController,    required this.videoUrls,    required this.coverPicUrl,    required this.videoImageUrls,    required this.model  });  Color makeStickyHeaderBgColor(shrinkOffset) {    final int alpha = (shrinkOffset / (this.maxExtent - this.minExtent) * 255)        .clamp(0, 255)        .toInt();    return Color.fromARGB(alpha, 255, 255, 255);  }  Color makeStickyHeaderTextColor(shrinkOffset, isIcon) {    if(shrinkOffset > 70){      this.isBlackIcon = true;    }else{      this.isBlackIcon = false;    }    if (shrinkOffset <= 50) {      return isIcon ? Colors.white : Colors.transparent;    } else {      final int alpha = (shrinkOffset / (this.maxExtent - this.minExtent) * 255)          .clamp(0, 255)          .toInt();      return Color.fromARGB(alpha, 0, 0, 0);    }  }  Widget videoPlayerView(url,context){    VideoPlayerController controller = VideoPlayerController.network(url);    Future _initializeVideoPlayerFuture = controller.initialize();    return GestureDetector(        child:Container(          margin: EdgeInsets.only(top: 5,bottom: 5),          child:  VideoPlayer(controller),          decoration: BoxDecoration(            shape: BoxShape.rectangle,            borderRadius: BorderRadius.all(Radius.circular(4)),          ),          clipBehavior: Clip.hardEdge,        ),        onTap:(){          Navigator.push<_PlayerVideoAndPopPage>(            context,            MaterialPageRoute<_PlayerVideoAndPopPage>(              builder: (BuildContext context) => _PlayerVideoAndPopPage(),            ),          );        }    );  }  @override  Widget build(BuildContext context, double shrinkOffset,      bool overlapsContent) {    return Container(      height: this.maxExtent,      width: MediaQuery          .of(context)          .size          .width,      child: Stack(        fit: StackFit.expand,        children: <Widget>[          // 背景图          GCBuildHouseHeader(coverImgUrls,videoUrls,videoImageUrls,coverPicUrl),          // 收起头部          Positioned(            left: 0,            right: 0,            top: 0,            child:Stack(              children: [                Positioned(child: Opacity(                  child: Container(                      height: 100,                      color: makeStickyHeaderBgColor(shrinkOffset),                  ),                  opacity:  (shrinkOffset/(MediaQuery.of(context).size.width*(266.0/375.0) - 108)<=0?0:((shrinkOffset/(MediaQuery.of(context).size.width*(266.0/375.0) - 108)>=1?1:shrinkOffset/(MediaQuery.of(context).size.width*(266.0/375.0) - 108)))),                ),),                SafeArea(                  bottom: false, child: Container(                  height: this.isBlackIcon? this.collapsedHeight:this.collapsedHeight,                  child: Column(                    children: [                      Row(                        mainAxisAlignment: MainAxisAlignment.spaceBetween,                        children: <Widget>[                          GestureDetector(                            child: Container(                              margin: EdgeInsets.only(left: 15),                              height: 24,width: 24,                              decoration: BoxDecoration(                                  image: DecorationImage(                                    image: !this.isBlackIcon? AssetImage("assets/homepage/left_anchor/icon_zuojiantou_B@2x.png"): AssetImage("assets/homepage/left_anchor/icon_zuojiantou_H@3x.png"),                                  )                              ),                            ),                            onTap: (){                              Navigator.pop(context);                            },                          ),                          Text(                            "樓盤詳情",                            style: TextStyle(                              fontSize: 20,                              fontWeight: FontWeight.w500,                              color: this.makeStickyHeaderTextColor(                                  shrinkOffset, false), // 标题颜色                            ),                          ),                          GestureDetector(                            child: Container(                              margin: EdgeInsets.only(right: 15),                              height: 24,width: 24,                              decoration: BoxDecoration(                                  image: DecorationImage(                                    image: this.isBlackIcon? AssetImage("assets/homepage/share_icon/icon_share_H@2x.png"): AssetImage("assets/homepage/share_icon/icon_fenxiang@2x.png"),                                  )                              ),                            ),                            onTap: ()async{                              if(Platform.isIOS) {                                const platform = const MethodChannel(                                    'gcglobal');                                var result;                                try {                                  //方法跟参数                                  print("调用了");                                  result = await platform.invokeMethod(                                      'ShareWeb', {                                    'title': model.name,                                    "link": model.webUrl!,                                    "image": model.imageUrl                                  });                                  print(result);                                  return Future.value(result);                                } on PlatformException catch (e) {                                  print("失败了");                                  print(result);                                  return Future.error(e.toString());                                }                              }else{                                showModalBottomSheet(                                    context: context,                                    builder: (BuildContext context) {                                      return Container(                                        color: Colors.transparent,//                          height: 120,                                        child: Container(                                          height: 245,                                          child: Column(                                            children: [                                              Container(                                                margin: EdgeInsets.only(top: 20),                                                child: Text(                                                  tr("分享至"),                                                  style: TextStyle(                                                      color:Color(0xFF333333),                                                      fontSize: 16                                                  ),                                                ),                                              ),                                              Container(                                                margin: EdgeInsets.only(top: 20),                                                child: Row(                                                  mainAxisAlignment: MainAxisAlignment.spaceAround,                                                  children: [                                                    GestureDetector(                                                      child: Container(                                                        child: Column(                                                          children: [                                                            Container(                                                              height: 60,                                                              width: 60,                                                              decoration: BoxDecoration(                                                                  shape: BoxShape.circle,                                                                  color:Color(0xFFF4F4F4)                                                              ),                                                              child: Container(                                                                  height: 30,                                                                  width: 30,                                                                  decoration: BoxDecoration(                                                                      image: DecorationImage(                                                                          image:AssetImage("assets/house_data/WhatsApp/icon_WhatsApp_D@2x.png")                                                                      )                                                                  )                                                              ),                                                            ),                                                            Container(                                                              margin: EdgeInsets.only(top:6 ),                                                              child: Text(                                                                "WhatsApp",                                                                style: TextStyle(                                                                    color:Color(0xFF333333),                                                                    fontSize: 12                                                                ),                                                              ),                                                            )                                                          ],                                                        ),                                                      ),                                                      onTap: ()async {                                                        print("分享whatsapp");                                                        String url = "https://wa.me/?text=${model.name!}${model.webUrl!}";                                                        var encoded = Uri.encodeFull(url);                                                        if (await canLaunch(encoded )) {                                                          await launch(encoded );                                                        } else {                                                          Fluttertoast.showToast(msg: tr("請檢查是否安裝了WhatsApp"));                                                        }                                                      },                                                    ),                                                    GestureDetector(                                                      child: Container(                                                        child: Column(                                                          children: [                                                            Container(                                                              height: 60,                                                              width: 60,                                                              decoration: BoxDecoration(                                                                  shape: BoxShape.circle,                                                                  color:Color(0xFFF4F4F4)                                                              ),                                                              child: Container(                                                                height: 30,                                                                width: 30,                                                                decoration: BoxDecoration(                                                                    image: DecorationImage(                                                                        image:AssetImage("assets/house_data/Facebook/icon_Facebook_D@2x.png")                                                                    )                                                                ),                                                              ),                                                            ),                                                            Container(                                                              margin: EdgeInsets.only(top:6 ),                                                              child: Text(                                                                "Facebook",                                                                style: TextStyle(                                                                    color:Color(0xFF333333),                                                                    fontSize: 12                                                                ),                                                              ),                                                            )                                                          ],                                                        ),                                                      ),                                                      onTap: (){                                                        print("分享fb");                                                        // FlutterShareMe().shareToFacebook(msg: widget.title!,url: widget.url!);                                                      },                                                    ),                                                    GestureDetector(                                                      child: Container(                                                        child: Column(                                                          children: [                                                            Container(                                                              height: 60,                                                              width: 60,                                                              decoration: BoxDecoration(                                                                shape: BoxShape.circle,                                                                color: Color(0xFFF4F4F4),                                                              ),                                                              child: Container(                                                                height: 30,                                                                width: 30,                                                                decoration: BoxDecoration(                                                                    image: DecorationImage(                                                                        image:AssetImage("assets/kehu_list/WeChat/icon_WeChat_D@2x.png"),                                                                        fit: BoxFit.contain                                                                    )                                                                ),                                                              ),                                                            ),                                                            Container(                                                              margin: EdgeInsets.only(top:6 ),                                                              child: Text(                                                                "WeChat",                                                                style: TextStyle(                                                                    color:Color(0xFF333333),                                                                    fontSize: 12                                                                ),                                                              ),                                                            )                                                          ],                                                        ),                                                      ),                                                      onTap: (){                                                      },                                                    )                                                  ],                                                ),                                              ),                                              GestureDetector(                                                child: Container(                                                  margin: EdgeInsets.only(top: 20),                                                  height: 36,width: 245,                                                  decoration: BoxDecoration(                                                      border: Border.all(color: Color(0xFFB03725)),                                                      borderRadius: BorderRadius.all(Radius.circular(4)),                                                      shape: BoxShape.rectangle                                                  ),                                                  child: Text(                                                    tr("取消"),                                                    style: TextStyle(                                                        color:Color(0xFFB03725),                                                        fontSize: 16                                                    ),                                                  ),                                                  alignment: Alignment.center,                                                ),                                                onTap: (){                                                  Navigator.pop(context);                                                },                                              )                                            ],                                          ),                                        ),                                      );                                    });                              }                              // print(model.imageUrl);                              // Share.share(model.webUrl!);                              // await FlutterShare.share(title: title,linkUrl: model.webUrl!);                            },                          ),                        ],                      ),                      // this.isBlackIcon?Container(                      //   margin: EdgeInsets.only(top: 0,left: 0,right: 0,bottom: 10),                      //   child: TabBar(                      //     labelStyle: TextStyle( //up to your taste                      //         fontWeight: FontWeight.w500,                      //       color: Color(0xFF333333),                      //       fontSize: 14                      //                      //     ),                      //     unselectedLabelStyle:  TextStyle( //up to your taste                      //         fontWeight: FontWeight.w400,                      //         color: Color(0xFF333333),                      //         fontSize: 14                      //                      //     ),                      //     labelPadding: EdgeInsets.zero,                      //     indicatorPadding: EdgeInsets.only(bottom: 10),                      //     controller: this.tagTabController,                      //     indicatorSize: TabBarIndicatorSize.label, //makes it better                      //     labelColor: Color(0xFF333333), //Google's sweet blue                      //     unselectedLabelColor: Color(0xFF333333), //niceish grey                      //     isScrollable: false, //up to your taste                      //     indicatorColor: Color(0xFF333333),                      //                      //     indicator: MaterialIndicator(                      //       height: 2,                      //       topLeftRadius: 0,                      //       topRightRadius: 0,                      //       bottomLeftRadius: 0,                      //       bottomRightRadius: 0,                      //       tabPosition: TabPosition.bottom,                      //       horizontalPadding: 10                      //     ),                      //     tabs: <Widget>[                      //       Tab(                      //         child: Container(                      //                      //           child:Text(                      //               "樓盤信息"                      //           )                      //         ),                      //       ),                      //       Tab(                      //         child: Container(                      //                      //             child:Text(                      //                 "360睇樓"                      //             )                      //         )                      //       ),                      //       Tab(                      //         child: Container(                      //                      //             child:Text(                      //                 "地產文件"                      //             )                      //         )                      //       ),                      //       Tab(                      //         child: Container(                      //                      //             child:Text(                      //                 "戶型介紹"                      //             )                      //         )                      //       ),                      //       Tab(                      //         child: Container(                      //                      //             child:Text(                      //                 "樓盤位置"                      //             )                      //         )                      //       )                      //     ],                      //   ),                      //                      // ):Container(),                    ],                  ),                ),),              ],            ),          ),        ],      ),    );  }  @override  double get maxExtent => this.expandedHeight;  @override  double get minExtent => this.collapsedHeight + this.paddingTop;  @override  bool shouldRebuild(SliverPersistentHeaderDelegate oldDelegate) {    return true;  }}class _PlayerVideoAndPopPage extends StatefulWidget {  @override  _PlayerVideoAndPopPageState createState() => _PlayerVideoAndPopPageState();}class _PlayerVideoAndPopPageState extends State<_PlayerVideoAndPopPage> {  late VideoPlayerController _videoPlayerController;  bool startedPlaying = false;  @override  void initState() {    super.initState();    _videoPlayerController =        VideoPlayerController.asset('assets/Butterfly-209.mp4');    _videoPlayerController.addListener(() {      if (startedPlaying && !_videoPlayerController.value.isPlaying) {        Navigator.pop(context);      }    });  }  @override  void dispose() {    _videoPlayerController.dispose();    super.dispose();  }  Future<bool> started() async {    await _videoPlayerController.initialize();    await _videoPlayerController.play();    startedPlaying = true;    return true;  }  @override  Widget build(BuildContext context) {    return Material(      elevation: 0,      child: Center(        child: FutureBuilder<bool>(          future: started(),          builder: (BuildContext context, AsyncSnapshot<bool> snapshot) {            if (snapshot.data == true) {              return AspectRatio(                aspectRatio: _videoPlayerController.value.aspectRatio,                child: VideoPlayer(_videoPlayerController),              );            } else {              return const Text('waiting for video to load');            }          },        ),      ),    );  }}